﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MReviewerClient.MReviewerSvc;

namespace MReviewerClient.Providers
{
    public static class ExtensionMethodsProvider
    {
        /// <summary>
        /// Determines whether this instance and another specified System.String object have the different value.
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool NonEquals(this string s, string value)
        {
            return !s.Equals(value);
        }

        /// <summary>
        /// Determines whether this instance is enable to convert to numeric
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool IsNumeric(this string s)
        {
            double val;
            return double.TryParse(s, out val);
        }

        /// <summary>
        /// Create a shallow copy of EstablishmentDTO
        /// </summary>
        /// <param name="original"></param>
        /// <returns></returns>
        public static EstablishmentDTO CreateShallowClone(this EstablishmentDTO original)
        {
            return new EstablishmentDTO
            {
                ID = original.ID,
                Name = original.Name,
                Location = original.Location,
                IDEstablishmentType = original.IDEstablishmentType,
                IDFoodType = original.IDFoodType
            };
        }

        /// <summary>
        /// Determinate the original object has not been modified
        /// </summary>
        /// <param name="original"></param>
        /// <param name="memento">The memento object</param>
        /// <returns></returns>
        public static bool IsNotModified(this EstablishmentDTO original, EstablishmentDTO memento)
        {
            if (original.ID == memento.ID &&
                original.IDEstablishmentType == memento.IDEstablishmentType &&
                original.IDFoodType == memento.IDFoodType &&
                original.Name.Equals(memento.Name, StringComparison.OrdinalIgnoreCase) &&
                original.Location.Equals(memento.Location, StringComparison.OrdinalIgnoreCase))
                return true;
            return false;
        }
    }
}
